package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.HousekeepingEnclosure;
import com.ruoyi.system.mapper.HousekeepingEnclosureMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.HousekeepingMapper;
import com.ruoyi.system.domain.Housekeeping;
import com.ruoyi.system.service.IHousekeepingService;

/**
 * 家政人员管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-06-16
 */
@Service
public class HousekeepingServiceImpl implements IHousekeepingService 
{
    @Autowired
    private HousekeepingMapper housekeepingMapper;
    @Autowired
    private HousekeepingEnclosureMapper housekeepingEnclosureMapper;

    /**
     * 查询家政人员管理
     * 
     * @param hId 家政人员管理ID
     * @return 家政人员管理
     */
    @Override
    public Housekeeping selectHousekeepingById(Long hId)
    {
        return housekeepingMapper.selectHousekeepingById(hId);
    }

    /**
     * 查询家政人员管理列表
     * 
     * @param housekeeping 家政人员管理
     * @return 家政人员管理
     */
    @Override
    public List<Housekeeping> selectHousekeepingList(Housekeeping housekeeping)
    {
        List<Housekeeping> housekeepings = housekeepingMapper.selectHousekeepingList(housekeeping);
        HousekeepingEnclosure housekeepingEnclosure = housekeeping.getHousekeepingEnclosure();
        for (int i = 0; i <housekeepings.size(); i++) {
            housekeepingEnclosure.sethId(housekeepings.get(i).gethId());
            housekeepings.get(i).setHousekeepingEnclosures(housekeepingEnclosureMapper.selectHousekeepingEnclosureList(housekeepingEnclosure));
        }
        return housekeepings;
    }

    /**
     * 新增家政人员管理
     * 
     * @param housekeeping 家政人员管理
     * @return 结果
     */
    @Override
    public int insertHousekeeping(Housekeeping housekeeping)
    {housekeeping.setCreateTime(DateUtils.getNowDate());
        return housekeepingMapper.insertHousekeeping(housekeeping);
    }

    /**
     * 修改家政人员管理
     * 
     * @param housekeeping 家政人员管理
     * @return 结果
     */
    @Override
    public int updateHousekeeping(Housekeeping housekeeping)
    {housekeeping.setUpdateTime(DateUtils.getNowDate());
        return housekeepingMapper.updateHousekeeping(housekeeping);
    }

    /**
     * 批量删除家政人员管理
     * 
     * @param hIds 需要删除的家政人员管理ID
     * @return 结果
     */
    @Override
    public int deleteHousekeepingByIds(Long[] hIds)
    {
        return housekeepingMapper.deleteHousekeepingByIds(hIds);
    }

    /**
     * 删除家政人员管理信息
     * 
     * @param hId 家政人员管理ID
     * @return 结果
     */
    @Override
    public int deleteHousekeepingById(Long hId)
    {
        return housekeepingMapper.deleteHousekeepingById(hId);
    }
}
